package com.hex.ds.hdrs.label.converter;

import com.hex.ds.hdrs.common.utils.BaseUtil;
import com.hex.ds.hdrs.common.utils.HdrsDateUtil;
import com.hex.ds.hdrs.label.dto.LabelInfoDto;
import com.hex.ds.hdrs.label.po.LabelInfoPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;


/**
 * @Package com.hex.ds.hdrs.label.converter
 * @ClassName ILabelInfoConverter
 * @Description LabelInfo表操作有关转换器
 * @Author yu liuyang
 * @Date 2023/4/17 18:10
 * @Version v1.0
 **/
@Mapper(componentModel = "spring", imports = {BaseUtil.class, HdrsDateUtil.class})
public interface ILabelInfoConverter {

    LabelInfoPo toLabelInfoPo(LabelInfoDto labelInfoDto);

    LabelInfoDto toLabelInfoDto(LabelInfoPo labelInfoPo);

    @Mapping(target = "pkId", expression = "java(BaseUtil.getPkId())")
    @Mapping(target = "crtUser", expression = "java(BaseUtil.getUserId())")
    @Mapping(target = "crtTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    @Mapping(target = "upUser", expression = "java(BaseUtil.getUserId())")
    @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    @Mapping(target = "labelStatus", defaultValue = "UNPUBLISHED")
    LabelInfoPo toLabelInfoPoForAdd(LabelInfoDto labelInfoDto);

    @Mapping(target = "upUser", expression = "java(BaseUtil.getUserId())")
    @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    LabelInfoPo toLabelInfoPoForEdit(LabelInfoDto labelInfoDto);

}
